Linux运行shell脚本提示No such file or directory错误的解决办法

您所在的位置:网站首页 no suchfileordirectory Linux运行shell脚本提示No such file or directory错误的解决办法

Linux运行shell脚本提示No such file or directory错误的解决办法

2023-11-18 12:33| 来源: 网络整理| 查看: 265

转载:

http://www.jb51.net/LINUXjishu/56395.html

http://www.sijitao.net/2368.html?utm_source=tuicool&utm_medium=referral

Linux执行.sh文件,提示No such file or directory的问题的解决方法:

Linux执行.sh文件,提示No such file or directory的问题:

原因:在windows中写好shell脚本测试正常,但是上传到 Linux 上以脚本方式运行命令时提示No such file or directory错误,那么一般是文件格式是dos格式的缘故,改成unix 格式即可。一般有如下几种修改办法。

1)在Windows下转换:  利用一些编辑器如UltraEdit或EditPlus等工具先将脚本编码转换,再放到Linux中执行。转换方式如下(UltraEdit):File-->Conversions-->DOS->UNIX即可。  2)方法  用vim打开该sh文件,输入: :set ff  回车,显示fileformat=dos,重新设置下文件格式: :set ff=unix  保存退出:  :wq  再执行,竟然可以了  3)在Linux中的权限转换  也可在Linux中转换:  首先要确保文件有可执行权限  #chmod u+x filename  然后修改文件格式  #vi filename  三种方法都可以方便快速的解决关于Linux执行.sh文件,提示No such file or directory这个问题了。  所以,程序尽量在Linux下编写,迁移时,也许会少很多问题。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3